#ifndef APPLICATION_H
#define APPLICATION_H

#include <QApplication>

class MainWindow;
class Document;
class ToolManager;
class StateManager;

class Application : public QApplication
{
    Q_OBJECT
public:
    explicit Application(int &argc, char **argv);

    static Application& app();
    
    bool initInstance();
    void exitInstance();

    QPointer<Document> createDocument();
    void setActiveDocument(QPointer<Document> doc);
    void removeDocument(QPointer<Document> doc);
    QPointer<Document> activeDocument() const;
    const DocumentList& documents() const;

    QPointer<StateManager> toolsStateManager() const;
    QPointer<QUndoGroup> undoGroup() const;
private:
    void initTools();
    void registerTools();
    QPointer<MainWindow> m_mainWindow;
    QPointer<ToolManager> m_toolManager;
    QPointer<StateManager> m_toolsStateManager;

    QPointer<QUndoGroup> m_undoGroup;
signals:
    void documentCreated(QPointer<Document> doc);
    void activeDocumentChanged(QPointer<Document> doc);
    void documentRemoved(QPointer<Document> doc);
public slots:
    
private slots:
};

#endif // APPLICATION_H
